package com.kaifamiao.www.IP.do0928;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class BroadReceiveDemo {
    public static void main(String[] args) throws IOException {
        //创建发送端对象
        DatagramSocket socket = new DatagramSocket(8888);
        //创建箱子，接收对象
        DatagramPacket packet = new DatagramPacket(new byte[1024],1024);//箱子大小byte
        //接收数据
        socket.receive(packet);
        //解析数据
        System.out.println(new String(packet.getData(),0,packet.getLength()));
        socket.close();
    }
}
